import Vue from 'vue';
import text from '../form/widget/text/textPropertyPanel.vue';
import radio from '../form/widget/radio/radioPropertyPanel.vue';
import checkbox from '../form/widget/checkbox/checkboxPropertyPanel.vue';
import number from '../form/widget/number/numberPropertyPanel.vue';
import cascadeSelect from '../form/widget/cascadeSelect/cascadePropertyPanel.vue';
import region from '../form/widget/region/regionPropertyPanel.vue';
import accessory from '../form/widget/accessory/accessoryPropertyPanel.vue';
import dateTime from '../form/widget/datetime/datetimePropertyPanel.vue';
import group from '../form/widget/group/groupPropertyPanel.vue';
import member from '../form/widget/member/memberPropertyPanel.vue';
import department from '../form/widget/department/depPropertyPanel.vue';
import associateSpare from '../form/widget/associateSpare/associateSparePanel.vue';
import associateService from '../form/widget/associateService/associateServicePanel.vue';
import associateUser from '../form/widget/associateUser/associateUserPanel.vue';
import sign from '../form/widget/sign/signPanel.vue';
const FormMap = {
  sign,
  associateUser,
  associateService,
  text,
  multiText: text,
  radio,
  checkbox,
  number,
  cascadeSelect,
  region,
  accessory,
  dateTime,
  group,
  member,
  department,
  associateSpare
};
export const currentForm = Vue.component('fieldForm', {
  functional: true,
  props: {
    form: {
      type: Object,
      required: true
    },
    fieldsList: {
      type: Array,
      required: true
    }
  },
  render (createElement, context) {
    const { fieldType } = context.props.form;
    const widget = FormMap[fieldType]
    return createElement(
      widget,
      { ...context.data, props: context.props }
    )
  }
})
